import configparser
import json

def get_config():
    config = configparser.ConfigParser(interpolation=None)
    config.read('config.ini', encoding='utf-8')
    return {
        "filepath": {
            "initial_state_file_path": config.get('filepath', 'initial_state_file_path'), # 初始状态文件夹
            "proxy_model_input_dir": config.get('filepath', 'proxy_model_input_dir'), # 代理模型输入文件夹
            "predict_result_dir": config.get('filepath', 'predict_result_dir'),
            "reflect_file_dir": config.get('filepath', 'reflect_file_dir'),
            "node_id_all_file_path": config.get('filepath', 'reflect_file_dir') + config.get('filepath', 'node_id_all_filename'), # 站点-序号映射文件路径
            "up_node_hour_flow_file_path": config.get('filepath', 'reflect_file_dir') + config.get('filepath', 'up_node_hour_flow_filename'), # 上游节点小时流量文件路径
            "down_node_hour_flow_file_path": config.get('filepath', 'reflect_file_dir') + config.get('filepath', 'down_node_hour_flow_filename'), # 下游节点小时流量文件路径
            "real_data_reflection_file_path": config.get('filepath', 'reflect_file_dir') + config.get('filepath', 'real_data_reflection_filename'), # 实时数据反射文件路径
            "input_node_feature_file_path": config.get('filepath', 'reflect_file_dir') + config.get('filepath', 'input_node_feature_filename'), # 输入节点特征文件路径
            "evaluation_chart_dir": config.get('filepath', 'evaluation_chart_dir'), # 评估图表目录名称
            "model_dir": config.get('filepath', 'model_dir'), # 模型目录
            "model_filename": config.get('filepath', 'model_filename'), # 模型文件路径
        },
        "api_url": {
            "base_ip_port": config.get('api_url', 'base_ip_port'),
            "flow_hour_url": config.get('api_url', 'base_ip_port') + config.get('api_url', 'flow_hour_url'), # low_hour数据URL
            "sensor_url": config.get('api_url', 'base_ip_port') + config.get('api_url', 'sensor_url'), # sensor数据URL
            "sensor_history_url": config.get('api_url', 'base_ip_port') + config.get('api_url', 'sensor_history_url'),
            "flow_history_url": config.get('api_url', 'base_ip_port') + config.get('api_url', 'flow_history_url'),
            "receive_station_predict_data_url": config.get('api_url', 'base_ip_port') + config.get('api_url', 'receive_station_predict_data_url'),
        },
        "project": {
            "start_port": config.get('project', 'start_port'),
            "open_swagger": config.get('project', 'open_swagger'),
            "time_format": config.get('project', 'time_format')
        }
    }

settings = get_config()
